#! /bin/bash

debug_node() {
    # 停止节点服务
    systemctl stop fast_backend.service
    # 更新开发目录配置信息
    cp ~/fast_backend/control_platform/* ~/code/node/fast_backend/control_platform
    cp ~/fast_backend/webconsole/backend/config/* ~/code/node/fast_backend/webconsole/backend/config/
    # 编译节点代码
    cd ~/code/node/fast_backend/webconsole/
    /usr/local/go/bin/go build server.go
    echo "代码更新完成，开始启动..."
    # 命令行运行节点代码
    sudo /usr/local/go/bin/go run server.go
}

debug_cluster() {
    systemctl stop cluster_backend.service
    cp ~/cluster_backend/config/* ~/code/cluster/fast_5g_controller_backend/config/

    cd ~/code/cluster/fast_5g_controller_backend/
    /usr/local/go/bin/go build main.go
    echo "代码更新完成，开始启动..."
    /usr/local/go/bin/go run main.go
}

case $1 in
"node_debug")
    debug_node
    ;;
"cluster_debug")
    debug_cluster
    ;;
esac
